package com.elementum.olegomatic.persist;

import com.elementum.olegomatic.dictionaries.DictId;
import com.elementum.olegomatic.dictionaries.Dictionary;
import com.elementum.olegomatic.dictionaries.DictionaryFactory;
import com.elementum.olegomatic.dictionaries.impl.DictionaryFactoryImpl;
import com.elementum.olegomatic.persist.impl.BasicDAOImpl;
import com.mongodb.DB;
import com.mongodb.DBCollection;
import com.mongodb.DBObject;
import com.mongodb.MongoClient;

import java.util.ArrayList;
import java.util.List;
import java.util.Set;

/**
 * Created with IntelliJ IDEA.
 * User: ravikolli
 * Date: 10/9/13
 * Time: 7:29 PM
 * To change this template use File | Settings | File Templates.
 */
public class EventReader{

    public static void main(String[] args){

        try{

            MongoClient client = new MongoClient("labs-nodejs.elementums.com", 27017);

            DB db = client.getDB("elementum_labs");

            Set<String> colls = db.getCollectionNames();

            if(!colls.isEmpty()){
                for (String s : colls) {
                    System.out.println(s);
                }
                DBCollection tweetsReceived = db.getCollection("tweetsReceived");
                System.out.println("Total Number of Tweets analyzed:"+ tweetsReceived.getCount());
                DBObject firstTweet = tweetsReceived.findOne();

                System.out.println(firstTweet.get("body"));

                BasicDAO impl = new BasicDAOImpl();
                List<Tweet> allTweets = impl.getReceivedTweets();
                System.out.println("OLEG!!!");

            }else{
                System.out.println("No Collections");
            }
        }catch(Exception e){
            e.printStackTrace();
        }
    }

    private void getSites(DB db){
        DictionaryFactory dictionFactory = new DictionaryFactoryImpl();

        Dictionary sites = dictionFactory.getDictionary(DictId.Sites);

        Dictionary keywords = dictionFactory.getDictionary(DictId.Events);




    }
}
